/* The file is saved in UTF-8 codepage.
 * Check: «Stereotype», Section mark-§, Copyright-©, Alpha-α, Beta-β, Smile-☺
 */
package cz.pecinovsky.english.lootp._101_;

import cz.pecinovsky.english.lootp._000_.Run;

import cz.pecinovsky.english.lootp.utility.NamedColor;
import cz.pecinovsky.english.lootp.utility.IO;

////%I+ <114
//import cz.pecinovsky.english.lootp.shapes.Canvas;
////%I-

////%I+ <110
//import cz.pecinovsky.english.lootp.shapes.Ellipse;
//import cz.pecinovsky.english.lootp.shapes.Rectangle;
//import cz.pecinovsky.english.lootp.shapes.Triangle;
////%I-

////%I+ >110 -014
//import cz.pecinovsky.english.lootp.shapes.Mover;
//
//import cz.pecinovsky.english.lootp.shapes.Ellipse;
//import cz.pecinovsky.english.lootp.shapes.Rectangle;
//import cz.pecinovsky.english.lootp.shapes.Triangle;
////%I-

import cz.pecinovsky.english.lootp.manager.Ellipse;
import cz.pecinovsky.english.lootp.manager.Rectangle;
import cz.pecinovsky.english.lootp.manager.Triangle;

import cz.pecinovsky.english.lootp.manager.Mover;


import cz.pecinovsky.english.lootp.manager.CanvasManager_Envelope.               CanvasManager;



////////////////////////////////////////////////////////////////////////////////
//%%+  +++++ End of ignored starting test - place for imports +++++
//%X+ xxxxx Start of the ovejumped text with declaration of the envelope xxxxx
/*******************************************************************************
 *<pre>
 * Předchozí:   Není - toto_je_nově_definovaná_třída
 *              Ttt v projektu Ppp
 * Následující: Prozatím není
 *
 * Projekt  Ppp
 *   + Přidáno
 *   - Odebráno
 *   ~ Změněno
 *</pre>
 */
public class Face_107_114
{    private Face_107_114() {}   static
////////////////////////////////////////////////////////////////////////////////
//%X- ----- End of the ovejumped text with declaration of the envelope -----


/*******************************************************************************
 * The class {@code Face} defines a set of unit tests
 * created in the interractive mode.
 *
 * @author Rudolf PECINOVSKÝ
 * @version 6.03.2017 — 2010-11-08
 */
public class Face extends junit.framework.TestCase
{
//%A+ >109
    private Ellipse   body;
//%A-
    private Rectangle head;
    private Ellipse   leftEye;
    private Ellipse   rightEye;
    private Ellipse   nose;
    private Ellipse   mouth;



//== CONSTANT CLASS ATTRIBUTES =================================================
//== VARIABLE CLASS ATTRIBUTES =================================================
//== STATIC CONSTRUCTOR (CLASS INITIALIZER, STATIC INICITALIZING BLOCK) ========
//== CONSTANT INSTANCE ATTRIBUTES ==============================================
//== VARIABLE INSTANCE ATTRIBUTES ==============================================
//== CLASS GETTERS AND SETTERS =================================================
//== OTHER NON-PRIVATE CLASS METHODS ===========================================

//##############################################################################
//== CONSTUCTORS AND FACTORY METHODS ===========================================

    /***************************************************************************
     * Creates a test with a given name.
     *
     * @param testName  The name of the created test
     */
    public Face(String testName)
    {
        super(testName);
    }



//== PREPARATION AND CLEANING THE FIXTURE ======================================

    /***************************************************************************
     * Creates a test fixture, i.e. a set of objects that will be prepared
     * before each run test.
     */
    @Override
    protected void setUp()
    {
//%A+ >109
        body     = new Ellipse  ( 0, 225, 300, 150, NamedColor.GREEN);
//%A-
        head     = new Rectangle( 50,  50, 200, 200);
        leftEye  = new Ellipse  ( 75,  75,  25,  25);
        rightEye = new Ellipse  (200,  75,  25,  25);
        nose     = new Ellipse  (125,  75,  50,  75);
        mouth    = new Ellipse  ( 75, 175, 150,  50);
//%A+ >114
        body     .paint();
        head     .paint();
        leftEye  .paint();
        rightEye .paint();
        nose     .paint();
        mouth    .paint();
//%A-
        IO.inform("Face prepared");
    }


    /***************************************************************************
     * Clean up after each test.
     */
    @Override
    protected void tearDown()
    {
    }



//== ABSTRACT METHODS ==========================================================
//== INSTANCE GETTERS AND SETTERS ==============================================
//== OTHER NON-PRIVATE INSTANCE METHODS ========================================
//== PRIVATE AND AUXILIARY CLASS METHODS =======================================
//== PRIVATE AND AUXILIARY INSTANCE METHODS ====================================
//== EMBEDDED TYPES AND INNER CLASSES ==========================================
//== THE TESTS =================================================================
//
//     /***************************************************************************
//      *
//      */
//     public void testXXX()
//     {
//     }

    public void testSmile()
    {
        mouth.setPosition(75, 150);
        mouth.setSize(150, 100);
        Rectangle ret = new Rectangle(75, 150, 150, 50);
//%A+ >114
        ret.paint();
//%A-
    }

//%A+ >108

    public void testBlink()
    {
        NamedColor hColor = head  .getColor();
        NamedColor eColor = leftEye.getColor();
        leftEye.setColor(hColor);
        IO.pause(250);
        leftEye.setColor(eColor);
    }

//%A-
//%A+ >=110z

    public void testCap()
    {
        Triangle cap = new Triangle(50, 0, 200, 50);
        cap.setPosition(50, -50);
//%A-
//%A+ >114
        cap.paint();
//%A-
//%A+ >=110z
        Mover mover = new Mover(5);
        mover.moveBy(0, 50, cap);
    }

//%A-
}

//%%- ---- Start of the ovejumped text with closing of the envelope ----
////////////////////////////////////////////////////////////////////////////////
//== TESTING CLASSES AND METHODS ===============================================
//If the class is not the testing one, the folowing two method can be removed
//%X+   Method prepared for inserting into tested classes
     /** */
     public void testFixture() {}

//%X-

    /***************************************************************************
     * Instances of the class {@code TearDown}
     * take care about cleaning up between particular tests
     * They executes the code, which is impossible to incorporate
     * into the method {@link #tearDown()},
     * until the students will not be able to program.
     */
    private static class TearDown implements Run.ITD
    {
        /** {@inheritDoc} */
        @Override
        public void cleanUp()
        {
//            Canvas.clearCanvas();
            CanvasManager.getInstance().removeAll();
        }
    }


    /***************************************************************************
     * Test method.
     */
    public static void test()
    {
        Run.tests(Face.class,
                new TearDown(),
//                "testFixture",
//                "testSmile",
//                "testBlink",
//                "testCap",
                "");
        System.exit(0);
    }
    /** @param args Command line arguments - they are not used. */
    public static void main(String[] args)  {  test();  }
}
